% Function :
% Parameter:
%   v: data(vector)
% Return:
%   idx: sorted indices of v in descending order(vector)
function idx = SortedIndex(v)
    % check input
    if ~isvector(v)
        error('input must be a vector');
    end

    n = numel(v);

    idx = 1 : n;

    for i = 2 : n
        key = idx(i);
        j = i;
        while j > 1 && v(idx(j - 1)) < v(key)
            idx(j) = idx(j - 1);
            j      = j - 1;
        end
        idx(j) = key;
    end
end
